package com.itheima.set;

import java.util.HashSet;
import java.util.Iterator;

public class Demo02 {

    public static void main(String[] args) {
        HashSet<String> set = new HashSet<>();
        set.add("啊啊");
        set.add("鹿鹿");
        set.add("滔滔");
        set.add("坤坤");
        set.add("签签");

        //迭代器
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()){
            String s = iterator.next();
            System.out.println(s);
        }
        System.out.println("============");
        //增强for
        for (String s : set) {
            System.out.println(s);
        }
        System.out.println("============");

        //foreach
        set.forEach(s -> System.out.println(s));


    }
}
